Skip to main content

Export And Commit Table Schemas

๐Ÿ“„ <ENV> - [BigQuery] Export and Commit Table Schemasโ€‹

This GitHub Actions workflow automates the extraction of BigQuery table schemas from the bqDataLake dataset and commits them to the repository. It helps ensure that your schema definitions remain version-controlled and in sync with BigQuery.


๐Ÿ“Œ Workflow Triggerโ€‹

This workflow is triggered manually via the GitHub actions in function repo.


๐Ÿ’  Environment Variablesโ€‹

VariableDescription
GCP_PROJECT_IDGCP Project ID (e.g., biddirect-2)
DATASET_IDBigQuery dataset ID (e.g., bqDataLake)

๐Ÿงฑ๏ธ Workflow Job: export-and-commit-bigquery-schemasโ€‹

StepDescription
Checkout repositoryClones the GitHub repository to the runner.
Authenticate with GCPAuthenticates using a service account (<ENV>_BIGQUERY_ADMIN_SERVICE_ACCOUNT) stored in GitHub Secrets.
Set up Cloud SDKInstalls and configures the Google Cloud SDK CLI.
Create output directoryCreates the directory to store schema JSON files.
Get all schemas from BigQueryIterates over all tables in the dataset (excluding _changelog and non-table types), exports schema definitions, and saves them to local files.
Commit and Push Schema FilesStages and commits any updated schema files to the repository.

๐Ÿงน Export Logic Summaryโ€‹

  • Skips tables ending with _changelog

  • Skips views or other non-TABLE resources

  • Removes _latest suffix from table names when naming schema files

  • Stores output in:

    functions/src/bqDataLake/definitions/tableSchemas/

Example:

Table: accounts_latest โ†’ File: accounts.json

๐Ÿ” Required Secretsโ€‹

Secret NameDescription
<ENV>_BIGQUERY_ADMIN_SERVICE_ACCOUNTService account key JSON for GCP auth.

โœ… Example Usageโ€‹

To run this workflow:

  1. Go to the Actions tab in your GitHub repository.
  2. Select the workflow <ENV> - [BigQuery] Export and Commit Table Schemas.
  3. Click "Run workflow".

This will:

  • Export schemas for all physical _latest tables in the bqDataLake dataset
  • Save each schema in JSON format to the repo
  • Automatically commit and push the updated files to the branch from which the workflow was executed

This workflow ensures that schema changes are tracked alongside application code.